<template>

  <div>
    <el-row :gutter="16">
      <el-col :span="8">
        <div class="statistic-card">
          <el-statistic title="本平台注册人次" :value="outputValue1" />
        </div>
      </el-col>
      <el-col :span="8">
        <div class="statistic-card">
          <el-statistic title="累计服务人次" :value="outputValue2" />
        </div>
      </el-col>
      <el-col :span="8">
        <div class="statistic-card">
          <el-statistic :value="98">
            <template #title>
              <div style="display: inline-flex; align-items: center">
                当日访问量
                <el-tooltip
                    effect="dark"
                    content="当日访问量"
                    placement="top"
                >
                  <el-icon style="margin-left: 4px" :size="12">
                    <Warning />
                  </el-icon>
                </el-tooltip>
              </div>
            </template>
          </el-statistic>
          <div class="statistic-footer">
            <div class="footer-item">
              <span>较昨天</span>
              <span class="green">
                24%
                <el-icon>
                  <CaretTop />
                </el-icon>
              </span>
            </div>
          </div>
        </div>
      </el-col>
    </el-row>
  </div>
  <div id="main" style="width: 800px; height: 600px;background-color: #FAFAFA;margin-top: 20px;"></div>
</template>

<script setup>
import { ref, onMounted, onUnmounted, nextTick } from 'vue';
import { CaretTop, Warning } from '@element-plus/icons-vue'
import * as echarts from 'echarts';
import { useTransition } from '@vueuse/core'

const source = ref(0)
const sources = ref(0)
const tableData = ref([])
const outputValue1 = useTransition(source, {
  duration: 3600,
})
const outputValue2 = useTransition(sources, {
  duration: 3600,
})
sources.value = 3600

/**
 * 查询学生用户信息
 */
const queryStuUserInfos =()=>{
  fetch("http://localhost:3000//TbUserinfoController/getUserInfos/2").then(res =>res.json().then(res =>{
    tableData.value = res.data;
    source.value = tableData.value.length;
    console.log(tableData.value);
  }))
}
onMounted(()=>{
  queryStuUserInfos()
})

onMounted(() => {
  // 获取DOM元素并且进行初始化
  var myChart = echarts.init(document.getElementById('main'));
  // 创建图标
  myChart.setOption({
    title: {
      text: '学辅星用户概况一览'
    },
    tooltip: {},
    xAxis: {
      data: ['信息工程学院', '经济与管理学院', '机械电气化工程学院', '人文院']
    },
    yAxis: {},
    series: [
      {
        name: '每院注册人数',
        type: 'bar',
        data: [20, 46, 10, 20]
      }
    ]
  })
})


</script>

<style scoped>
:global(h2#card-usage ~ .example .example-showcase) {
  background-color: var(--el-fill-color) !important;
}

.el-statistic {
  --el-statistic-content-font-size: 28px;
}

.statistic-card {
  height: 80px;
  padding: 20px;
  border-radius: 4px;
  box-shadow: 10px 10px 5px #909399;
  background-color: var(--el-bg-color-overlay);
}

.statistic-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--el-text-color-regular);
  margin-top: 16px;
}

.statistic-footer .footer-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.statistic-footer .footer-item span:last-child {
  display: inline-flex;
  align-items: center;
  margin-left: 4px;
}

.green {
  color: var(--el-color-success);
}

</style>
